﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Globalization;
using System.Web.Mvc;
using System.Web.Security;
using System.Data;
using System.Data.Entity;
using System.Linq;
using System.Web;
using FantasyBlog.DAL;

namespace FantasyBlog.Models
{
    public class AdminPostModel
    {


        public AdminPostModel()
        {
            PostSet = db.PostSet;
            TotalRecordCount = PostSet.Count();
            CurrentPage = 1;
            PageSize = 5;
            SortBy = "ID";
            SortAsc = true;
            list = PostSet.ToList();
        }

        public IEnumerable<FantasyBlog.DAL.Post> list;

        //public IEnumerable<FantasyBlog.DAL.Category> list;

        private BlogModelContainer db = new BlogModelContainer();

        public DbSet<Post> PostSet;

        public string SortBy { get; set; }

        public bool SortAsc { get; set; }

        public int CurrentPage { get; set; }

        public int PageSize { get; set; }

        public int TotalRecordCount { get; set; }

        public int PageCount
        {
            get
            {
                if (TotalRecordCount % PageSize == 0)
                {
                    return TotalRecordCount / PageSize;
                }
                else
                {
                    return TotalRecordCount / PageSize + 1;
                }
            }
        }
    }


    public class CreatePostModel
    {
        [Required]
        [Display(Name = "文章标题")]
        public string PostTitle { get; set; }

        [Required]
        [Display(Name = "文章正文")]
        public string PostContent { get; set; }

        [Display(Name = "文章摘要")]
        public string PostExcerpt { get; set; }

    }
}
